<template>
  <div>
    <a-carousel :autoplay="true" dot-position="right" dots="false" :slides-to-show="num" :slides-to-scroll="1" id="carousel">
      <div class="todo-item" v-for="(item,index) in todoList" :key="index">
        <div class="todo-type">
          [{{item.matterTypeName}}]
        </div>
        <div class="todo-text" ref="todoText">
          <TableTootip :content="item.matterContent" :width="textWidth"></TableTootip>
        </div>
        <div class="todo-time">
          {{item.noticeDatetime}}
        </div>
        <div class="todo-status" :class="{'over':item.urgency=='001','success':item.urgency=='002','error':item.urgency=='003'}">
          {{item.urgencyName}}
        </div>
      </div>
    </a-carousel>
    <div class="nodata" v-if="!todoList.length">暂无数据</div>
  </div>
</template>
<script>
import {req} from "../../../api/axiosFun";
import TableTootip from '../../../components/TableTootipHome.vue'
export default {
  components:{
    TableTootip
  },
  data() {
    return{
      todoList:[],
      textWidth: 0,
      num:5
    }
  },
  mounted() {
    this.getTodoList()
  },
  methods:{
    //异常待解决问题
    getTodoList() {
      req('post', `dataBoard/getTodoList`)
        .then(res => {
          if (res.result === 'success') {
            this.todoList = res.data
            this.num = this.todoList.length<5?this.todoList.length:5
            setTimeout(()=>{
              if(this.$refs.todoText){
                this.textWidth = this.$refs.todoText[0].offsetWidth
              }
            },100)
          }
        })
    },
  }
}
</script>
<style scoped>
@import "../../../assets/css/maincss.css";
.todo-item {
  display: flex!important;
  padding: 0 5px;
  line-height: 38px;
  font-size: 14px;
}
.todo-type {
  margin-right: 5px;
  color: #0092FC;
}
.todo-text {
  flex: 1;
  width: 0;
  margin-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.todo-status {
  margin-left: 10px;
}
/deep/ .ant-carousel .slick-list {
  height: 170px;
}
.ant-carousel >>> .slick-slide{
  width: 100%;
}
@media screen and (max-width: 1440px) {
  .todo-item {
    font-size: 12px;
  }
}
</style>
